<form id="add-form" class="form-horizontal  nice-validator n-default n-bootstrap"  data-toggle="validator" method="POST" action="{:url('store/editPost')}" >

    <div class="form-group">
        <label for="store_name" class="control-label col-xs-12 col-sm-2">店铺名称:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="store_name" id="store_name" class="form-control" value="{$info.store_name}">
        </div>
    </div>
    <input type="hidden" name="id" value="{$info.id}">
    <div class="form-group">
        <label for="address" class="control-label col-xs-12 col-sm-2">店铺地址:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="address" id="address" class="form-control"  value="{$info.address}">
        </div>
    </div>
    <div class="form-group">
        <label for="address" class="control-label col-xs-12 col-sm-2">店铺电话:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="mobile" id="mobile" class="form-control"  value="{$info.mobile}">
        </div>
    </div>
    <div class="form-group">
        <label for="mav" class="control-label col-xs-12 col-sm-2">店铺介绍:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="mav" id="mav" class="form-control"  value="{$info.mav}">
        </div>
    </div>
    <div class="form-group">
        <label for="price" class="control-label col-xs-12 col-sm-2">价格(分钟):</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="price" id="price" class="form-control"  value="{$info.price}">
        </div>
    </div>
    <div class="form-group">
        <label for="s_time" class="control-label col-xs-12 col-sm-2">收费开始(24小时制):</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="s_time" id="s_time" class="form-control"  value="{$info.s_time}">
        </div>
    </div>
    <div class="form-group">
        <label for="e_time" class="control-label col-xs-12 col-sm-2">收费开始(24小时制):</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" name="e_time" id="e_time" class="form-control"  value="{$info.e_time}">
        </div>
    </div>
    <div class="form-group">
        <label for="level" class="control-label col-xs-12 col-sm-2">店铺级别:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="level" >
                {foreach name='level' item='vo'}
                {if condition='$vo.id eq $info.level'}
                <option value="{$vo.id}" selected>{$vo.name}</option>
                {else/}
                <option value="{$vo.id}" >{$vo.name}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="cat_store" class="control-label col-xs-12 col-sm-2">店铺类别:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="cat_store" >
                {foreach name='classify' item='vo'}
                {if condition='$vo.id eq $info.cat_store'}
                <option value="{$vo.id}" selected>{$vo.name}</option>
                {else/}
                <option value="{$vo.id}">{$vo.name}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="provinceid" class="control-label col-xs-12 col-sm-2">省:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="provinceid" id="provinceid">
                {foreach name='provinces' item='vo'}
                {if condition="$vo.provinceid eq $info.provinceid"}
                <option value="{$vo.provinceid}" selected>{$vo.province}</option>
                {else/}
                <option value="{$vo.provinceid}">{$vo.province}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="cityid" class="control-label col-xs-12 col-sm-2">市:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="cityid" id="cityid" >
                {foreach name='city' item='vo'}
                {if condition="$vo.cityid eq $info.cityid"}
                <option value="{$vo.cityid}" selected>{$vo.city}</option>
                {else/}
                <option value="{$vo.cityid}">{$vo.city}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="areaid" class="control-label col-xs-12 col-sm-2">县:</label>
        <div class="col-xs-12 col-sm-8">
            <select name="areaid" id="areaid" >
                {foreach name='areas' item='vo'}
                {if condition="$vo.areaid eq $info.areaid"}
                <option value="{$vo.areaid}" selected>{$vo.area}</option>
                {else/}
                <option value="{$vo.areaid}">{$vo.area}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="uname" class="control-label col-xs-12 col-sm-2">内容:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea name="content"  class="form-control">{$info.content}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label for="uname" class="control-label col-xs-12 col-sm-2">课程:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea name="course"  class="form-control">{$info.course}</textarea>
        </div>
    </div>
   <!-- <div class="form-group">
        <label for="uname" class="control-label col-xs-12 col-sm-2">相册:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="file" id="file" name="file" accept="image/*">
            <input type="file" id="file1" name="file1" accept="image/*">
            <input type="file" id="file2" name="file2" accept="image/*">
        </div>
        <input type="hidden" id="img" name="img" value="">
        <input type="hidden" id="img1" name="img1" value="">
        <input type="hidden" id="img2" name="img2" value="">
    </div>-->
    <div class="form-group layer-footer">
        <div class="col-xs-2"></div>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed">提交</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="/assets/js/jquery-1.9.1.min.js"></script>
<!-- 实例化编辑器 -->
<link rel='stylesheet' href='/assets/editor/themes/default/default.css' />
<link rel='stylesheet' href='/assets/editor/plugins/code/prettify.css'/>
<script language='javascript' src='/assets/editor/kindeditor.js'></script>
<script language='javascript' src='/assets/editor/lang/zh_CN.js'></script>
<script language='javascript' src='/assets/editor/plugins/code/prettify.js'></script>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name=content]',{

            uploadJson : '/assets/editor/php/upload_json.php',
            fileManagerJson : '/assets/editor/php/file_manager_json.php',

            allowFileManager : true,
            afterBlur: function(){editor.sync();}

        });

    });
    var course;
    KindEditor.ready(function(K) {
        course = K.create('textarea[name=course]',{

            uploadJson : '/assets/editor/php/upload_json.php',
            fileManagerJson : '/assets/editor/php/file_manager_json.php',

            allowFileManager : true,
            afterBlur: function(){course.sync();}

        });

    });
    /*图片上传*/
    $("#file").on("change",function(){
        var formData = new FormData();
        formData.append('file', this.files[0]);
        $.ajax({
            url: "{:url('store/img')}",
            type: 'POST',
            data: formData,
            cache: false,
            processData: false,
            contentType: false
        }).done(function(res) {
            if(res.msg.num == 1)
            {
                $('#img').val(res.msg.con);
            }else{
                alert(res.msg.con);
            }
            /*  var sr='<img id="img" style="width: 100%;height: 100%" src="__ROOT__/upload/upload/'+res.msg.con+'"/>'
             $('.img-up-box').html(sr);
             $('#name').val(res.msg.con);*/
        }).fail(function(res) {});
    });
    $("#file1").on("change",function(){
        var formData = new FormData();
        formData.append('file', this.files[0]);
        $.ajax({
            url: "{:url('store/img')}",
            type: 'POST',
            data: formData,
            cache: false,
            processData: false,
            contentType: false
        }).done(function(res) {
            if(res.msg.num == 1)
            {
                $('#img1').val(res.msg.con);
            }else{
                alert(res.msg.con);
            }
            /*  var sr='<img id="img" style="width: 100%;height: 100%" src="__ROOT__/upload/upload/'+res.msg.con+'"/>'
             $('.img-up-box').html(sr);
             $('#name').val(res.msg.con);*/
        }).fail(function(res) {});
    });
    $("#file2").on("change",function(){
        var formData = new FormData();
        formData.append('file', this.files[0]);
        $.ajax({
            url: "{:url('store/img')}",
            type: 'POST',
            data: formData,
            cache: false,
            processData: false,
            contentType: false
        }).done(function(res) {
            if(res.msg.num == 1)
            {
                $('#img2').val(res.msg.con);
            }else{
                alert(res.msg.con);
            }
            /*  var sr='<img id="img" style="width: 100%;height: 100%" src="__ROOT__/upload/upload/'+res.msg.con+'"/>'
             $('.img-up-box').html(sr);
             $('#name').val(res.msg.con);*/
        }).fail(function(res) {});
    });
    /*三级联动*/
    $('#provinceid').change(function () {
        var provinces=$('#provinceid option:selected').val();
        $.post("{:url('store/city')}",{provinces:provinces},function (date) {
            var con="";
            $.each(date.msg,function(k,v){
                con +='<option value='+v.cityid+' >'+v.city+'</option>'
                $('#cityid').html(con);
            })
        })
    })
    $('#cityid').change(function(){
        var city=$('#cityid option:selected').val();
        if(city==0)
        {
            alert("请选择市级单位");
            return false;
        }
        $.post("{:url('store/areas')}",{city:city},function (date) {
            var con="";
            $.each(date.msg,function(k,v){
                con +='<option value='+v.areaid+' >'+v.area+'</option>'
                $('#areaid').html(con);
            })
        })
    })
</script>
